

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Edit Task</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>
            <span class="menuButton"><g:link class="list" action="list">Task List</g:link></span>
            <span class="menuButton"><g:link class="create" action="create">New Task</g:link></span>
        </div>
        <div class="body">
            <h1>Edit Task</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${task}">
            <div class="errors">
                <g:renderErrors bean="${task}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <input type="hidden" name="id" value="${task?.id}" />
                <div class="dialog">
                    <table>
                        <tbody>
							<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="reporter">Reporter:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:task,field:'reporter','errors')}">
                                    <g:select optionKey="id" from="${User.list()}" name="reporter.id" value="${task?.reporter?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="description">Description:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:task,field:'description','errors')}">
                                    <textarea id="description" name="description" value="${fieldValue(bean:task,field:'description')}" rows="2" cols="65"></textarea>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="estimatedHours">Estimated Hours:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:task,field:'estimatedHours','errors')}">
                                    <input type="text" id="estimatedHours" name="estimatedHours" value="${fieldValue(bean:task,field:'estimatedHours')}" />
                                </td>
                            </tr> 
							<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="remainingHours">Remaining Hours:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:task,field:'remainingHours','errors')}">
                                    <input type="text" id="remainingHours" name="remainingHours" value="${fieldValue(bean:task,field:'remainingHours')}" />
                                </td>
                            </tr> 
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="owner">Owner:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:task,field:'owner','errors')}">
                                    <g:select optionKey="id" from="${User.list()}" name="owner.id" value="${task?.owner?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="state">State:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:task,field:'state','errors')}">
                                    <input type="text" id="state" name="state" value="${fieldValue(bean:task,field:'state')}"/>
                                </td>
                            </tr> 
							<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="lastUpdateDate">Last Update Date:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:task,field:'lastUpdateDate','errors')}">
                                    <g:datePicker name="lastUpdateDate" value="${task?.lastUpdateDate}" ></g:datePicker>
                                </td>
                            </tr> 
                        
							<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="comments">Comments:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:task,field:'comments','errors')}">
                                    
									<ul>
										<g:each var="c" in="${task?.comments?}">
										    <li><g:link controller="comment" action="show" id="${c.id}">${c}</g:link></li>
										</g:each>
									</ul>
									<g:link controller="comment" params="["task.id":task?.id]" action="create">Add Comment</g:link>

                                </td>
                            </tr> 
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" value="Update" /></span>
                    <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
